import bge

scene = bge.logic.getCurrentScene()

owner = bge.logic.getCurrentController().owner

scene.objects["Cube"].endObject()